package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.DataBean;

/**
 * Created by mc on 2018/11/7.
 * yang-wen-wen
 */

public class ItemOrderInfoAdapter extends BaseQuickImageAdapter<DataBean> {

    public ItemOrderInfoAdapter(Context context) {
        super(context, R.layout.item_order_info);
    }

    @Override
    protected void convert(BaseViewHolder helper, DataBean item) {
        helper.setText(R.id.tv_left, item.getLeftStr())
                .setText(R.id.tv_right, item.getRightStr())
                .addOnClickListener(R.id.iv_tag);

        if (item.isHaveBg()) {
            helper.getView(R.id.root).setBackground(mContext.getResources().getDrawable(R.drawable.shape_gray_bg));
        } else {
            helper.getView(R.id.root).setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }

        if (item.isTop()) {
            helper.getView(R.id.null_view).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.null_view).setVisibility(View.GONE);
        }
        if (item.getTagImg() > 0) {
            helper.getView(R.id.iv_tag).setVisibility(View.VISIBLE);
            helper.setImageDrawable(R.id.iv_tag, mContext.getResources().getDrawable(item.getTagImg()));
        } else {
            helper.getView(R.id.iv_tag).setVisibility(View.GONE);
            helper.setImageDrawable(R.id.iv_tag, null);
        }
    }


}
